home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / antispam / RazorAgent_SDK / razor-agents-sdk-2.03.exe / URI-1.19 / t / ldap.t < prev    next >
Encoding:
Text File  |  2000-08-02  |  2.6 KB  |  88 lines

  1. #!perl
  2.  
  3. print "1..15\n";
  4.  
  5. use URI;
  6.  
  7. $url = URI->new("ldap://host/dn=base?cn,sn?sub?objectClass=*");
  8.  
  9. print "not " unless $url->host eq "host";
  10. print "ok 1\n";
  11.  
  12. print "not " unless $url->dn eq "dn=base";
  13. print "ok 2\n";
  14.  
  15. print "not " unless join("-",$url->attributes) eq "cn-sn";
  16. print "ok 3\n";
  17.  
  18. print "not " unless $url->scope eq "sub";
  19. print "ok 4\n";
  20.  
  21. print "not " unless $url->filter eq "objectClass=*";
  22. print "ok 5\n";
  23.  
  24. $uri = URI->new("ldap:");
  25. $uri->dn("o=University of Michigan,c=US");
  26.  
  27. print "not " unless "$uri" eq "ldap:o=University%20of%20Michigan,c=US" &&
  28.     $uri->dn eq "o=University of Michigan,c=US";
  29. print "ok 6\n";
  30.  
  31. $uri->host("ldap.itd.umich.edu");
  32. print "not " unless $uri->as_string eq "ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US";
  33. print "ok 7\n";
  34.  
  35. # check defaults
  36. print "not " unless $uri->_scope  eq "" &&
  37.                     $uri->scope   eq "base" &&
  38.                     $uri->_filter eq "" &&
  39.                     $uri->filter  eq "(objectClass=*)";
  40. print "ok 8\n";
  41.  
  42. # attribute
  43. $uri->attributes("postalAddress");
  44. print "not " unless $uri eq "ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress";
  45. print "ok 9\n";
  46.  
  47. # does attribute escapeing work as it should
  48. $uri->attributes($uri->attributes, "foo", ",", "*", "?", "#", "\0");
  49.  
  50. print "not " unless $uri->attributes eq "postalAddress,foo,%2C,*,%3F,%23,%00" &&
  51.                     join("-", $uri->attributes) eq "postalAddress-foo-,-*-?-#-\0";
  52. print "ok 10\n";
  53. $uri->attributes("");
  54.  
  55. $uri->scope("sub?#");
  56. print "not " unless $uri->query eq "?sub%3F%23" &&
  57.                     $uri->scope eq "sub?#";
  58. print "ok 11\n";
  59. $uri->scope("");
  60.  
  61. $uri->filter("f=?,#");
  62. print "not " unless $uri->query eq "??f=%3F,%23" &&
  63.                     $uri->filter eq "f=?,#";
  64.  
  65. $uri->filter("(int=\\00\\00\\00\\04)");
  66. print "not " unless $uri->query eq "??(int=%5C00%5C00%5C00%5C04)";
  67. print "ok 12\n";
  68.  
  69.  
  70. print "ok 13\n";
  71. $uri->filter("");
  72.  
  73. $uri->extensions("!bindname" => "cn=Manager,co=Foo");
  74. my %ext = $uri->extensions;
  75.  
  76. print "not " unless $uri->query eq "???!bindname=cn=Manager%2Cco=Foo" &&
  77.                     keys %ext == 1 &&
  78.                     $ext{"!bindname"} eq "cn=Manager,co=Foo";
  79. print "ok 14\n";
  80.  
  81. $uri = URI->new("ldap://LDAP-HOST:389/o=University%20of%20Michigan,c=US?postalAddress?base?ObjectClass=*?FOO=Bar,bindname=CN%3DManager%CO%3dFoo");
  82.  
  83. print "not " unless $uri->canonical eq "ldap://ldap-host/o=University%20of%20Michigan,c=US?postaladdress???foo=Bar,bindname=CN=Manager%CO=Foo";
  84. print "ok 15\n";
  85.  
  86. print "$uri\n";
  87. print $uri->canonical, "\n";
  88.